<template>
  <div style="height: 100%">
    <el-header class="header">
      <div>欢迎来到后台管理页面</div>
      <div>管理员：{{username}} 你好 <el-button type="primary" @click="logout">退出</el-button></div>
    </el-header>
    <el-container style="height: 100%; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246);height: 100%;">
        <el-menu>
          <el-submenu index="1">
            <template slot="title"
              ><i class="el-icon-message"></i>首页</template
            >
            <el-menu-item-group>
              <router-link to="/"
                ><el-menu-item index="1-1">首页</el-menu-item></router-link
              >
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"
              ><i class="el-icon-menu"></i>订单管理</template
            >
            <el-menu-item-group>
              <router-link to="/allOrder"
                ><el-menu-item index="2-1">全部订单</el-menu-item></router-link
              >
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"
              ><i class="el-icon-setting"></i>人员管理</template
            >
            <el-menu-item-group>
              <router-link to="/peopleManagement"
                ><el-menu-item index="3-1">全部人员</el-menu-item></router-link
              >
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
        <el-main style="height: 100%">
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "Home",
  props: {
    msg: String,
  },
  data() {
    return {
      username:''
    };
  },
  created(){
    let username = sessionStorage.getItem('username')
    this.username = username
  },
  methods:{
    logout(){
      sessionStorage.removeItem('token');
      sessionStorage.removeItem('username');
      this.$router.push("/login");
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.el-header {
  background-color: #000000;
  color: rgb(255, 255, 255);
  line-height: 60px;
}

.el-aside {
  color: #333;
}
.header {
  font-size: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
